package com.windowes.weichang.controller.common;

import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.pojo.Splash;
import com.windowes.weichang.service.SplashService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/5/29 下午11:02
 * @description:
 *
 **/
@RestController
@RequestMapping("splash")
@Api(description = "app引导页API")
public class SplashController {


    @Autowired
    SplashService splashService;

    @ApiOperation(value = "获取引导页列表", notes = "")
    @GetMapping("list")
    @ApiImplicitParam(name = "limit", value = "最多获取记录数,默认不传,为5条", dataType = "int", paramType = "query")
    public ServerResponse list(@RequestParam(defaultValue = "5") Integer limit) {
        return splashService.list(limit);
    }


    @ApiOperation(value = "添加/更新引导页信息", notes = "添加与更新的区别在于是否提交id")
    @PostMapping("addOrUpdate")
    @ApiImplicitParam(name = "splash", value = "添加或更新引导页", required = true, dataType = "Splash")
    public ServerResponse list(@RequestBody Splash splash) {
        return splashService.insertOrUpdate(splash);
    }

}
